package org.common.utils.function;

import java.util.function.Function;

public interface FunctionThrows<T , R> extends Function<T , R> {

    static <T , R> Function<T , R> of(FunctionThrows<T , R> functionThrows) {
        return functionThrows;
    }

    @Override
    default R apply(T t) {
        try {
            return applyImpl(t);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    R applyImpl(T t) throws Exception;
}
